var t = getApp();

Page({
    data: {
        mobile: "",
        start1: !1,
        codetext: "获取短信验证码",
        newPwdBol: !0,
        newPwdBolConfirm: !0,
        newPwd: "",
        newPwdConfirm: "",
        code: ""
    },
    onLoad: function(t) {
        this._getBalancePwdInfo();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    pwdinp: function() {
        this.setData({
            popupSpecs: !0
        });
    },
    rePwdinp: function(t) {
        this.setData({
            popupSpecs2: !0
        });
    },
    popupSpecsClose: function(t) {
        this.setData({
            popupSpecs: !1
        });
    },
    popupSpecsClose2: function(t) {
        this.setData({
            popupSpecs2: !1
        });
    },
    onPassword: function(t) {
        this.setData({
            newPwd: t.detail
        });
    },
    onPassword2: function(t) {
        this.setData({
            newPwdConfirm: t.detail
        });
    },
    _getBalancePwdInfo: function() {
        var e = this, o = t.getNetAddresss("member.balance-password.is-has-password");
        t._getNetWork({
            url: o,
            success: function(t) {
                var o = t.data;
                1 == o.result ? o.data.is_has ? e.setData({
                    mobile: o.data.mobile
                }) : wx.showModal({
                    title: "提示",
                    content: "先绑定手机号",
                    success: function(t) {
                        t.confirm ? wx.navigateTo({
                            url: "../../member/editmobile/editmobile"
                        }) : t.cancel && wx.navigateBack({
                            delta: 1
                        });
                    }
                }) : wx.showToast({
                    icon: "none",
                    title: o.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    },
    codeinp: function(t) {
        var e = t.detail.value;
        this.setData({
            code: e.trim()
        });
    },
    sendCode: function(t) {
        if (this.data.start1) return !1;
        var e = 60, o = this;
        o.setData({
            start1: !0,
            codetext: "(" + e + ")秒后重新获取"
        });
        var n = setInterval(function() {
            o.setData({
                codetext: "(" + --e + ")秒后重新获取"
            });
        }, 1e3);
        setTimeout(function() {
            o.setData({
                codetext: "获取短信验证码",
                start1: !1
            }), clearInterval(n);
        }, 6e4), o.verificationCode(n);
    },
    verificationCode: function(e) {
        if (t._isTextEmpty(this.data.mobile) || t._isMoblie(this.data.mobile)) return wx.showToast({
            icon: "none",
            title: "手机号数据错误",
            duration: 1500
        }), void this.setData({
            codetext: "获取短信验证码",
            start1: !1
        });
        // var o = t.getNetAddresss("member.balance-password.send-code");
        var o = t.getNetAddresss("SMS.index");
        o += "&mobile=" + this.data.mobile, t._getNetWork({
            url: o,
            success: function(t) {
                var e = t.data;
                1 == e.result ? wx.showToast({
                    icon: "none",
                    title: "已发送",
                    duration: 1500
                }) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    submitInfo: function() {
        if (t._isTextEmpty(this.data.code)) return t.tips("验证码不能为空");
        if (t._isTextEmpty(this.data.newPwd)) return t.tips("新密码不能为空");
        if (t._isTextEmpty(this.data.newPwdConfirm)) return t.tips("新密码不能为空");
        if (this.data.newPwd != this.data.newPwdConfirm) return t.tips("密码不一致");
        var e = t.getNetAddresss("member.balance-password.update-password");
        e += "&password=" + this.data.newPwd, e += "&confirmed=" + this.data.newPwdConfirm, 
        e += "&code=" + this.data.code, e += "&mobile=" + this.data.mobile, t._getNetWork({
            url: e,
            success: function(t) {
                var e = t.data;
                1 == e.result ? (wx.showToast({
                    icon: "none",
                    title: "修改成功",
                    duration: 1500
                }), setTimeout(function() {
                    wx.navigateBack({
                        delta: 1
                    });
                }, 1500)) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    newPwdshow: function() {
        this.data.newPwdBol ? this.setData({
            newPwdBol: !1
        }) : this.setData({
            newPwdBol: !0
        });
    },
    newPwdConfirmshow: function() {
        this.data.newPwdBolConfirm ? this.setData({
            newPwdBolConfirm: !1
        }) : this.setData({
            newPwdBolConfirm: !0
        });
    }
});